
package br.ufu.lsi.database.temp;

import java.io.File;
import java.io.IOException;

import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;

public class ScriptExecutor {

    private static final String COMMAND = "sh /Users/fabiola/Applications/tweetf0rm-master/client.sh -c config.json -cmd CRAWL_USER_TIMELINE -uid ";

    private static final String WORKING_DIR = "/Users/fabiola/Applications/tweetf0rm-master";
    
    
    public void runCollector() {
        
        
    }

    public void runScript( String param ) {

        try {
            
            CommandLine oCmdLine = CommandLine.parse( COMMAND + param );
            DefaultExecutor oDefaultExecutor = new DefaultExecutor();
            oDefaultExecutor.setWorkingDirectory( new File( WORKING_DIR ) );
            oDefaultExecutor.setExitValue( 0 );
            oDefaultExecutor.execute( oCmdLine );

        } catch ( IOException e ) {

            System.err.println( "permission denied." );
            e.printStackTrace();
        }
    }

    public static void main( String args[] ) {
        ScriptExecutor script = new ScriptExecutor();
        script.runScript( "18297088" );
    }

}
